package com.lbssoft.gpsbd.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lbssoft.gpsbd.dao.StatisticsStopMapper;
import com.lbssoft.gpsbd.model.Result;
import com.lbssoft.gpsbd.model.StatisticsStop;
import com.lbssoft.gpsbd.service.StatisticsStopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by nczc on 2018/10/16.
 */
@Service
public class StatisticsStopServiceImpl implements StatisticsStopService {

    @Autowired
    private StatisticsStopMapper statisticsStopMapper;

    @Override
    public Result getList(long deviceId, int page, int pageSize) {
        Result result = new Result();
        PageHelper.startPage(page, pageSize);
        List<StatisticsStop> list = statisticsStopMapper.list(deviceId);
        PageInfo pageInfo = new PageInfo(list);
        Page pages = (Page) list;
        Map data = new HashMap();
        data.put("page", page);
        data.put("total", pageInfo.getTotal());
        data.put("list", pages);
        result.setData(data);
        return result;
    }
}
